<%-- 
  -- Body Edit para User Password.
  --
  -- @author pablo.tortorella
--%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/struts-html-el-1.2.8.tld" prefix="html-el"%>
<%@ taglib uri="/WEB-INF/struts-logic-el-1.2.8.tld" prefix="logic-el"%>
<%@ taglib uri="/WEB-INF/security.tld" prefix="security" %>

<%@ taglib uri="http://struts.apache.org/tags-bean-el" prefix="bean2"%>


<script src="<html:rewrite page='/protected/script/util.js'/>" type="text/javascript"></script>

<%-- Para EXT --%>
<link rel="stylesheet" type="text/css" href="<html:rewrite page='/protected/script/ext-1.1.1/resources/css/ext-all.css'/>" />

<script src="<html:rewrite page='/protected/script/ext-1.1.1/adapter/ext/ext-base.js'/>" type="text/javascript"></script>
<script src="<html:rewrite page='/protected/script/ext-1.1.1/ext-all.js'/>" type="text/javascript"></script>

<link rel="stylesheet" type="text/css" href="<html:rewrite page='/protected/style/dragdrop.css'/>" id="styleFile"/>

<%-- prototype esta en el main layout --%>
<script src="<html:rewrite page='/protected/script/scriptaculous/scriptaculous.js'/>" type="text/javascript"></script>

<script type="text/javascript">
    /** Modifica el password del usuario */
    function modify() {
        if (Util.valid.isBlank($("passwordId").value)) {
            Ext.MessageBox.alert('Error', 'Debe ingresar password. ');
            return;
        }        
        if (Util.valid.isBlank($("passwordConfirmationId").value)) {
            Ext.MessageBox.alert('Error', 'Debe ingresar confirmacion de password. ');
            return;
        }        
        if ($("passwordId").value != $("passwordConfirmationId").value) {
            Ext.MessageBox.alert('Error', 'Los passwords ingresados no coinciden. ');
            return;
        }

		$("modifyNameId").value = $("nameId").value;
        $("modifyRealNameId").value = $("realNameId").value;
        $("modifySurnameId").value = $("surnameId").value;
        $("modifyPasswordId").value = $("passwordId").value;
        
        var form = $("modifyUserFormId");
        form.submit();
    } 
</script>

<%-- El ID del form NO debe ser modificado. Se usa desde el menu --%>
<html:form action="/protected/showUser.do" styleId="userFormId">
    <%-- Inyectados por Javascript --%>
    <html:hidden name="userForm" property="name" styleId="nameId"/>
    
    <h2>Cambiar Password</h2>
    
    <div class="userEdit">
        <table class="tableData" cellspacing="0">
            <tr>
                <td class="tableDataTitle">
                    Usuario
                </td>
                <td class="tableDataValue">
                    <html:text property="name" styleId="nameId" readonly="true" />
                </td>            
            </tr>
            <tr>
                <td class="tableDataTitle">
                    Nombre
                </td>
                <td class="tableDataValue">
                    <html:text property="realName" styleId="realNameId" readonly="true" />
                </td>            
            </tr>
            <tr>
                <td class="tableDataTitle">
                    Apellido
                </td>
                <td class="tableDataValue">
                    <html:text property="surname" styleId="surnameId" readonly="true" />
                </td>            
            </tr>
            <tr>
                <td class="tableDataTitle">
                    Password*
                </td>
                <td class="tableDataValue">
                    <html:password property="password" styleId="passwordId" />
                </td>            
            </tr>
            <tr>
                <td class="tableDataTitle">
                    Confirmar*
                </td>
                <td class="tableDataValue">
                    <html:password property="passwordConfirmation" styleId="passwordConfirmationId" />
                </td>            
            </tr>
        </table>
    
        <div id="clear">
        </div>
       	<p class="mensajeCamposObligatorios">Los campos marcados con un asterisco (*) son obligatorios.</p>
        <div id="clear">
        </div>
        
        <div class="panelButton">
            <input type="button" value="Modificar" onclick="modify();" title="Modifica el usuario..." class="button">
        </div>  
    
    </div>

</html:form>

<%-- Inyectados por Javascript --%>
<div id="modifyUserDivId" class="hideClass">
    <html:form action="/protected/modifyPassword" styleId="modifyUserFormId">
        <html:hidden property="name" value="" styleId="modifyNameId" />
        <html:hidden property="realName" value="" styleId="modifyRealNameId" />
        <html:hidden property="surname" value="" styleId="modifySurnameId" />
        <html:hidden property="password" value="" styleId="modifyPasswordId" />
    </html:form>
</div>